package com.ruoyi.api.factory;


import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.ruoyi.api.RemoteAuthService;
import com.ruoyi.api.common.R;
import com.ruoyi.api.domain.LDAPLoginDTO;
import com.ruoyi.api.domain.LoginDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 技术平台服务降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteAuthServiceFallbackFactory implements FallbackFactory<RemoteAuthService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteAuthServiceFallbackFactory.class);

    @Override
    public RemoteAuthService create(Throwable throwable) {
        log.error("技术平台服务调用失败:{}", throwable.getMessage());
        return new RemoteAuthService() {

            @Override
            public R<String> ldapLogin(LDAPLoginDTO dto) {
                return R.fail("ldap登录接口调用失败");
            }

            @Override
            public R<LoginDTO> getUserInfoByTicket(String ticket) {
                return R.fail("根据ticket返回用户信息接口调用失败");
            }

        };
    }
}
